import java.lang.management.PlatformManagedObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-06
 * Time: 15:27
 */
public class Test34 {
    public static class ListNode {
        int val;
        ListNode next;

        ListNode(int val) {
            this.val = val;
            next = null;
        }
        ListNode() {

        }
    }

    public static ListNode mergeKLists(ListNode[] lists) {
        return merge(lists,0,lists.length-1);
    }

    public static ListNode merge(ListNode[] lists,int left,int right) {
        if(left > right) {
            return null;
        }
        if(left == right) {
            return lists[left];
        }

        int mid = (left+right) / 2;

        ListNode l1 = merge(lists,left,mid);
        ListNode l2 = merge(lists,mid+1,right);

        return mergeTwo(l1,l2);
    }

    public static ListNode mergeTwo(ListNode left, ListNode right) {
        ListNode newHead = new ListNode();
        ListNode cur = newHead;

        while(left != null && right != null) {
            if(left.val < right.val) {
                cur.next = left;
                left = left.next;
            }else {
                cur.next = right;
                right = right.next;
            }
            cur = cur.next;
        }
        cur.next = left != null ? left : right;
        return newHead.next;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ListNode[] lists = new ListNode[n];

        for(int i = 0; i < n; i++) {
            ListNode head = null, tail = null;
            int m = sc.nextInt();
            for(int j = 0; j < m; j++) {
                int val = sc.nextInt();
                ListNode node = new ListNode(val);
                if(head == null) {
                    head = node;
                } else {
                    tail.next = node;
                }
                tail = node;
            }
            lists[i] = head;
        }
        ListNode ret = mergeKLists(lists);
        while(ret != null) {
            System.out.print(ret.val+" ");
            ret = ret.next;
        }
    }
}
